home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / pvmgs / pvm_gstat.c < prev    next >
C/C++ Source or Header  |  1997-07-22  |  4KB  |  108 lines

  1.  
  2. static char rcsid[] =
  3.     "$Id: pvm_gstat.c,v 1.3 1997/07/09 13:51:25 pvmsrc Exp $";
  4.  
  5. /*
  6.  *         PVM version 3.4:  Parallel Virtual Machine System
  7.  *               University of Tennessee, Knoxville TN.
  8.  *           Oak Ridge National Laboratory, Oak Ridge TN.
  9.  *                   Emory University, Atlanta GA.
  10.  *      Authors:  J. J. Dongarra, G. E. Fagg, M. Fischer
  11.  *          G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci,
  12.  *         P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam
  13.  *                   (C) 1997 All Rights Reserved
  14.  *
  15.  *                              NOTICE
  16.  *
  17.  * Permission to use, copy, modify, and distribute this software and
  18.  * its documentation for any purpose and without fee is hereby granted
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both the copyright notice and this permission notice appear in
  21.  * supporting documentation.
  22.  *
  23.  * Neither the Institutions (Emory University, Oak Ridge National
  24.  * Laboratory, and University of Tennessee) nor the Authors make any
  25.  * representations about the suitability of this software for any
  26.  * purpose.  This software is provided ``as is'' without express or
  27.  * implied warranty.
  28.  *
  29.  * PVM version 3 was funded in part by the U.S. Department of Energy,
  30.  * the National Science Foundation and the State of Tennessee.
  31.  */
  32.  
  33. /*
  34.    pvm_gstat - print the status of all groups held 
  35. */
  36.  
  37. #include <stdio.h>
  38. #include "pvm3.h"
  39. #include "pvmalloc.h"
  40. #include "pvmgsd.h"
  41.  
  42. #define NEWMEM(p,n,t) \
  43.     if (p != (t *) NULL) \
  44.         PVM_FREE(p); \
  45.     p = (t *) PVM_ALLOC(n  * sizeof(t) ,"pvm_gstat")
  46.  
  47. int
  48. main(argc, argv)
  49. int argc;
  50. char *argv[];
  51. {
  52.     int mytid, gstid;
  53.     int i, j, ng; 
  54.     GROUP_STRUCT group;
  55.         group.len = 0; group.name = (char *) NULL;
  56.         group.tids = (int *) NULL; group.btids = (int *) NULL;
  57.         mytid = pvm_mytid();
  58.     if((gstid = gs_getgstid()) < 0) 
  59.         {
  60.             fprintf(stderr, "%s: no groups server\n", argv[0]);
  61.             return(-1);
  62.         }
  63.         pvm_initsend(PvmDataDefault);
  64.         pvm_send(gstid, GSLS);
  65.         if ( pvm_recv(gstid, GSLS) < 0) 
  66.         {
  67.              fprintf(stderr, "Error receiving message from group server\n");
  68.              exit (-1);
  69.         }
  70.        
  71.         /* Unpack the information for each group                           */
  72.         pvm_upkint(&ng, 1, 1);
  73.         if (ng == 0)
  74.             fprintf(stdout, "no groups exist\n");
  75.         for (i = 0; i < ng; i++) 
  76.         {
  77.             pvm_upkint(&(group.len),1,1);
  78.             NEWMEM(group.name, group.len+1,char);
  79.             pvm_upkstr(group.name);
  80.             pvm_upkint(&(group.ntids), 1, 1);
  81.             pvm_upkint(&(group.maxntids), 1,1);
  82.             pvm_upkint(&(group.barrier_count), 1, 1);
  83.             pvm_upkint(&(group.barrier_reached),1,1);
  84.             NEWMEM(group.tids, group.maxntids, int);
  85.             NEWMEM(group.btids, group.barrier_reached, int);
  86.             pvm_upkint(group.tids, group.maxntids, 1);
  87.             if (group.barrier_reached > 0)
  88.                 pvm_upkint(group.btids, group.barrier_reached, 1);
  89.             fprintf(stdout, 
  90.                 "group: %s, size: %d,  barrier_count %d, barrier_reached %d\n",
  91.                  group.name, group.ntids, group.barrier_count, 
  92.                  group.barrier_reached);
  93.             fputs("tids:\n", stdout);
  94.             for (j = 0; j < group.maxntids; j++)
  95.                 if (group.tids[j] > 0)
  96.                     fprintf(stdout, "%d 0x%x\t", j, group.tids[j]);
  97.             fputs("\n", stdout);
  98.             if (group.barrier_reached > 0) 
  99.             {
  100.                 fputs("tids waiting on barrier:\n", stdout);
  101.                 for (j = 0; j < group.barrier_reached; j++)
  102.                      fprintf(stdout, "0x%x\t", group.btids[j]);
  103.                 fputs("\n", stdout);
  104.             }
  105.         }
  106.     pvm_exit();
  107. }
  108.